import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart' hide Action;

import '../action.dart';
import 'action.dart';
import 'state.dart';

Widget buildView(ClassState state, Dispatch dispatch, ViewService viewService) {
  return Container(
    padding: const EdgeInsets.fromLTRB(8.0, 0, 8.0, 0),
    child: Card(
        color: Colors.white,
        elevation: 5.0,
        margin: new EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0),
        child: ListTile(
          onTap: () => dispatch(ClassActionCreator.onClick(state.id)),
          title: Row(
            children: <Widget>[
              Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  SizedBox(height: 8),
                  Text(state.name),
                  Text('班级ID：${state.id}'),
                  Text(state.teacherName),
                  SizedBox(height: 8),
                ],
              ),
              Spacer(),
              FlatButton(
                child: Column(
                  children: <Widget>[
                    Container(
                        decoration: BoxDecoration(
                          shape: BoxShape.circle,
                          color: Colors.blue,
                        ),
                        child: Padding(
                          padding: EdgeInsets.all(10),
                          child: Image.asset("assets/images/exit.png",
                              width: 24, height: 24, fit: BoxFit.cover),
                        )),
                    Text(
                      '移除班级',
                      style: TextStyle(fontSize: 12),
                    ),
                  ],
                ),
                onPressed: () =>
                    dispatch(ClassListActionCreator.onDelete(state.id)),
              ),
            ],
          ),
        )),
  );
}
